home *** CD-ROM | disk | FTP | other *** search
/ Sports Illustrated Multimedia Almanac 1995 / Sports Illustrated Multimedia Almanac (1995)(StarPress)[Mac-PC].iso / pc / msregdb.inc < prev    next >
Text File  |  1994-12-09  |  5KB  |  154 lines

  1. rem $$Begin$$
  2.  
  3. rem Copyright:    (c) 1994 StarPress Multimedia. All Rights Reserved.
  4. rem
  5. rem Project:      Sports Illustrated Multimedia Almanac
  6. rem
  7. rem Component:    Installer
  8. rem
  9. rem Description:  MSSETUP includes
  10. rem
  11. rem ---------------------------------------------------------------------
  12. rem
  13. rem   $Author:   NSJ  $
  14. rem
  15. rem     $Date:   06 Jul 1994 17:32:32  $
  16. rem
  17. rem      $Log:   S:/almanac.vcs/install/msregdb.inv  $
  18. rem
  19. rem  $Logfile:   S:/almanac.vcs/install/msregdb.inv  $
  20. rem
  21. rem $Workfile:   msregdb.inc  $
  22. rem
  23. rem ---------------------------------------------------------------------
  24.  
  25. rem $$End$$
  26.  
  27. '***************************************************************************
  28. '****************     registration database api's    ***********************
  29. '***************************************************************************
  30.  
  31. '$DEFINE REG_DB_ENABLED
  32.  
  33. const REG_SZ               = 1
  34. const HKEY_CLASSES_ROOT    = 1
  35. const ERROR_SUCCESS        = 0
  36.  
  37.  
  38. DECLARE FUNCTION EercErrorHandler LIB "mscomstf.dll" (grc%, fVital%, sz1$, sz2$, sz3$) AS INTEGER
  39. CONST GRC_API_FAILED       = 104
  40.  
  41. DECLARE FUNCTION RegOpenKey LIB "SHELL.DLL" (hKey&, szSubKey$, phkResult AS POINTER TO LONG) AS LONG
  42. DECLARE FUNCTION RegCreateKey LIB "shell.dll" (hKey&, szSubKey$, phkResult AS POINTER TO LONG) AS LONG
  43. DECLARE FUNCTION RegDeleteKey LIB "shell.dll" (hKey&, szSubKey$) AS LONG
  44. DECLARE FUNCTION RegCloseKey LIB "shell.dll" (hKey&) AS LONG
  45. DECLARE FUNCTION RegQueryValue LIB "shell.dll" (hKey&, szSubKey$, szValue$, lpcb AS POINTER TO LONG) AS LONG
  46. DECLARE FUNCTION RegSetValue LIB "shell.dll" (hKey&, szSubKey$, dwType&, szValue$, cbValue&) AS LONG
  47. DECLARE FUNCTION RegEnumKey LIB "shell.dll" (HkEY&, dwIndex&, szBuffer$, dwBufferSize&) AS LONG
  48.  
  49.  
  50. DECLARE SUB CreateRegKey(szKey$)
  51. DECLARE SUB CreateRegKeyValue(szKey$, szValue$)
  52. DECLARE SUB SetRegKeyValue(szKey$, szValue$)
  53. DECLARE SUB DeleteRegKey(szKey$)
  54. DECLARE FUNCTION GetRegKeyValue(szKey$) AS STRING
  55. DECLARE FUNCTION DoesRegKeyExist(szKey$) AS INTEGER
  56.  
  57.  
  58. 'NOTE: All keys are assumed to be subkeys of HKEY_CLASSES_ROOT. Therefore,
  59. 'the key HKEY_CLASSES_ROOT\key1\key2 would simply be written as key1\key2
  60. 'for these api's.
  61.  
  62.  
  63. '**************************************************************************
  64. SUB CreateRegKey(szKey$) STATIC
  65.     DIM phKey AS LONG
  66.  
  67.     IF RegCreateKey(HKEY_CLASSES_ROOT, szKey$, VARPTR(phKey)) > ERROR_SUCCESS THEN
  68.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKey", NULL, NULL)
  69. '$ifdef DEBUG
  70.         StfApiErr saeFail, "CreateRegKey", szKey$
  71. '$endif ''DEBUG
  72.         ERROR STFERR
  73.     END IF
  74.  
  75.     IF RegCloseKey(phKey) > ERROR_SUCCESS THEN
  76.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKey", NULL, NULL)
  77. '$ifdef DEBUG
  78.         StfApiErr saeFail, "CreateRegKey", szKey$
  79. '$endif ''DEBUG
  80.         ERROR STFERR
  81.     END IF
  82. END SUB
  83.  
  84.  
  85. '**************************************************************************
  86. SUB CreateRegKeyValue(szKey$, szValue$) STATIC
  87.     DIM phKey AS LONG
  88.  
  89.     IF RegSetValue(HKEY_CLASSES_ROOT, szKey$, REG_SZ,  szValue$, len(szKey$)) > ERROR_SUCCESS THEN
  90.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKeyValue", NULL, NULL)
  91. '$ifdef DEBUG
  92.         StfApiErr saeFail, "CreateRegKeyValue", szKey$+", "+szValue$
  93. '$endif ''DEBUG
  94.         ERROR STFERR
  95.     END IF
  96. END SUB
  97.  
  98.  
  99. '**************************************************************************
  100. FUNCTION DoesRegKeyExist(szKey$) STATIC AS INTEGER
  101.     DIM phKey AS LONG
  102.  
  103.     IF RegOpenKey(HKEY_CLASSES_ROOT, szKey$, VARPTR(phKey)) = ERROR_SUCCESS THEN
  104.         i = RegCloseKey(phKey)
  105.         DoesRegKeyExist = 1
  106.     ELSE
  107.         DoesRegKeyExist = 0
  108.     ENDIF
  109. END FUNCTION
  110.  
  111.  
  112. '**************************************************************************
  113. SUB SetRegKeyValue(szKey$, szValue$) STATIC
  114.     DIM phKey AS LONG
  115.  
  116.     IF RegSetValue(HKEY_CLASSES_ROOT, szKey$, REG_SZ,  szValue$, len(szKey$)) > ERROR_SUCCESS THEN
  117.         i% = EercErrorHandler(GRC_API_FAILED, 1, "SetRegKeyValue", NULL, NULL)
  118. '$ifdef DEBUG
  119.         StfApiErr saeFail, "SetRegKeyValue", szKey$+", "+szValue$
  120. '$endif ''DEBUG
  121.         ERROR STFERR
  122.     END IF
  123. END SUB
  124.  
  125.  
  126. '**************************************************************************
  127. FUNCTION GetRegKeyValue(szKey$) STATIC AS STRING
  128.     szValue$ = string$(512,32)
  129.     cb& = len(szValue$)
  130.  
  131.     IF DoesRegKeyExist(szKey$) = 0 THEN
  132.         GetRegKeyValue = ""
  133.         EXIT FUNCTION
  134.     END IF
  135.  
  136.     IF RegQueryValue(HKEY_CLASSES_ROOT, szKey$, szValue$, VARPTR(cb)) = ERROR_SUCCESS THEN
  137.         GetRegKeyValue = MID$(szValue$, 1, cb)
  138.     ELSE
  139.         i% = EercErrorHandler(GRC_API_FAILED, 1, "SetRegKeyValue", NULL, NULL)
  140. '$ifdef DEBUG
  141.         StfApiErr saeFail, "GetRegKeyValue", szKey$
  142. '$endif ''DEBUG
  143.         ERROR STFERR
  144.     END IF
  145.   szValue$ = ""
  146. END FUNCTION
  147.  
  148.  
  149. '**************************************************************************
  150. SUB DeleteRegKey(szKey$) STATIC
  151.     i& = RegDeleteKey(HKEY_CLASSES_ROOT, szKey$)
  152. END SUB
  153.  
  154.